package com.itheima.mapper;

import com.itheima.pojo.Role;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 根据用户名获取用户信息
     * @param username
     * @return
     */
    @Select("select * from  t_user where username = #{username}")
    List<User> getUser(String username);

    /**
     * 根据用户id查询权限id
     * @param id
     * @return
     */
    @Select("select * from t_user_role where user_id = #{id}")
    List<Role> getRoleByUserId(Integer id);

    /**
     * 根据id获取用户权限
     * @param roleId
     * @return
     */
    @Select("select * from t_role where id = #{roleId}")
    Role getRoleById(Integer roleId);
}
